<template>
	<div style="width: 100%;height: 100%">
		<el-form class="search-form form-inline" label-width="120px" size="mini" ref="info">
			<el-row>
				<el-col :span="8">
					<el-form-item class="form-group" label="姓名：">
						<el-input v-model="info.username" disabled />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item class="form-group" label="性别：">
						<el-input v-model="info.sex" disabled />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item class="form-group" label="联系方式：">
						<el-input v-model="info.phone" disabled />
					</el-form-item>
				</el-col>
			</el-row>
			<el-row>
				<el-col :span="8">
					<el-form-item class="form-group" label="身份证号">
						<el-input v-model="info.cardId" disabled />
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<el-row>
			<el-button type="primary" plain @click="updatePassword()">修改密码</el-button>
		</el-row>
		<el-dialog title="修改密码" :visible.sync="dialogVisible" width="40%" :before-close="handleClose">
			<el-form class="search-form form-inline" label-width="120px" size="mini" ref="info">
				<el-row>
					<el-col :span="24">
						<el-form-item class="form-group" label="新密码">
							<el-input v-model="password" />
						</el-form-item>
					</el-col>
				</el-row>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="dialogVisible = false">取 消</el-button>
				<el-button type="primary" @click="save">确 定</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		props: {
			account: {
				type: String
			},
			username: {
				type: String
			}
		},
		data() {
			return {

				info: {

				},
				dialogVisible: false,
				password: ''
			}
		},
		methods: {
			updatePassword() {
				this.dialogVisible = true
			},
			save() {
				this.$axios.get("http://localhost:8888/user/updatePassword?password=" + this.password + "&id=" + this.info
						.id)
					.then((data) => {
						console.log(data)
						this.dialogVisible = false
						this.$message.success("修改成功！")
					})
			}
		},
		mounted() {
			this.$axios.post("http://localhost:8888/user/byUsername", {
				username: this.username
			}).then((data) => {
				console.log(data)
				this.info = data.data[0]
			})
		}
	}
</script>

<style>
</style>
